/**
 *    Copyright (C) 2008, 2009  Victor Smirnov <aist11@gmail.com>
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *    See LICENSE.exceptions in the root folder of this project for possible
 *    exceptions
 *
 */

#ifndef _CUBEFS_API_REFLECTION_VALUE_HPP
#define	_CUBEFS_API_REFLECTION_VALUE_HPP

#include <cubefs/api/reflection/type.hpp>
#include <cubefs/api/reflection/type_hash.hpp>

namespace cubefs    {
namespace api       {

struct CUBEFS_API Value: public Typed {

	virtual void SetManaged(bool managed0) 				= 0;

	virtual void set(const void* value) 				= 0;
	virtual void get(void* value) const 				= 0;

	virtual void Set(const Value* value) 				= 0;

	virtual bool IsEquals(const Value* val) const		= 0;

	static Type* MyType();
};

CUBEFS_DECLARE_TYPENAME(Value, "cubefs::api::Value");

template <typename T>
struct CUBEFS_API TypedValue: public Value {
    virtual const T& GetValue() const 					= 0;
    virtual void SetValue(const T& value)				= 0;
    static Type* MyType() {
    	return GetTypedValueType(TypeHash<T>::hash);
    }
};

CUBEFS_API Type* GetTypedValueType(Int type_hash_code);

typedef TypedValue<void*>       						VoidPtrValue;
typedef TypedValue<const void*> 						ConstVoidPtrValue;
typedef TypedValue<bool>								BooleanValue;
typedef TypedValue<String>								StringValue;
typedef TypedValue<StringRef>							StringRefValue;
typedef TypedValue<const String>						ConstStringValue;


extern CUBEFS_API BooleanValue* 						TYPED_TRUE;
extern CUBEFS_API BooleanValue* 						TYPED_FALSE;

CUBEFS_LIST_VALUE_TRAITS(StringValue, 		TypedValueType);




CUBEFS_DECLARE_PARAMETRIZED_TYPENAME(TypedValue, "cubefs::api::TypedValue");

struct CUBEFS_API VoidValue: public Value {
    static Type* MyType();
};

CUBEFS_DECLARE_TYPENAME(VoidValue, "cubefs::api::VoidValue");

}
}



#endif

